home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 January: Mac OS SDK / Dev.CD Jan 00 SDK1.toast / Development Kits / Mac OS / QuickTime / QuickTime 3 Interfaces & Libs / QTDevWin / CIncludes / TranslationExtensions.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-21  |  6.8 KB  |  209 lines  |  [TEXT/dosa]

  1. /*
  2.      File:        TranslationExtensions.h
  3.  
  4.      Contains:    Macintosh Easy Open Translation Extension Interfaces.
  5.  
  6.      Version:    Technology:    Macintosh Easy Open 1.1
  7.                  Release:    QuickTime 3.0
  8.  
  9.      Copyright:    © 1989-1993, 1995, 1997-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __TRANSLATIONEXTENSIONS__
  19. #define __TRANSLATIONEXTENSIONS__
  20.  
  21. #ifndef __MACTYPES__
  22. #include <MacTypes.h>
  23. #endif
  24. #ifndef __FILES__
  25. #include <Files.h>
  26. #endif
  27. #ifndef __QUICKDRAW__
  28. #include <Quickdraw.h>
  29. #endif
  30. #ifndef __COMPONENTS__
  31. #include <Components.h>
  32. #endif
  33.  
  34.  
  35.  
  36. #if PRAGMA_ONCE
  37. #pragma once
  38. #endif
  39.  
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43.  
  44. #if PRAGMA_IMPORT
  45. #pragma import on
  46. #endif
  47.  
  48. #if PRAGMA_STRUCT_ALIGN
  49.     #pragma options align=mac68k
  50. #elif PRAGMA_STRUCT_PACKPUSH
  51.     #pragma pack(push, 2)
  52. #elif PRAGMA_STRUCT_PACK
  53.     #pragma pack(2)
  54. #endif
  55.  
  56.  
  57. enum {
  58.     kSupportsFileTranslation    = 1,
  59.     kSupportsScrapTranslation    = 2,
  60.     kTranslatorCanGenerateFilename = 4
  61. };
  62.  
  63.  
  64. /* better names for 4-char codes*/
  65. typedef OSType                             FileType;
  66. typedef ResType                         ScrapType;
  67. typedef unsigned long                     TranslationAttributes;
  68.  
  69. enum {
  70.     taDstDocNeedsResourceFork    = 1,
  71.     taDstIsAppTranslation        = 2
  72. };
  73.  
  74.  
  75.  
  76. struct FileTypeSpec {
  77.     FileType                         format;
  78.     long                             hint;
  79.     TranslationAttributes             flags;                        /* taDstDocNeedsResourceFork, taDstIsAppTranslation*/
  80.     OSType                             catInfoType;
  81.     OSType                             catInfoCreator;
  82. };
  83. typedef struct FileTypeSpec                FileTypeSpec;
  84.  
  85. struct FileTranslationList {
  86.     unsigned long                     modDate;
  87.     unsigned long                     groupCount;
  88.                                                                 /*     unsigned long    group1SrcCount;*/
  89.                                                                 /*     unsigned long    group1SrcEntrySize = sizeof(FileTypeSpec);*/
  90.                                                                 /*  FileTypeSpec    group1SrcTypes[group1SrcCount]*/
  91.                                                                 /*  unsigned long    group1DstCount;*/
  92.                                                                 /*  unsigned long    group1DstEntrySize = sizeof(FileTypeSpec);*/
  93.                                                                 /*  FileTypeSpec    group1DstTypes[group1DstCount]*/
  94. };
  95. typedef struct FileTranslationList        FileTranslationList;
  96. typedef FileTranslationList *            FileTranslationListPtr;
  97. typedef FileTranslationListPtr *        FileTranslationListHandle;
  98.  
  99.  
  100. struct ScrapTypeSpec {
  101.     ScrapType                         format;
  102.     long                             hint;
  103. };
  104. typedef struct ScrapTypeSpec            ScrapTypeSpec;
  105.  
  106. struct ScrapTranslationList {
  107.     unsigned long                     modDate;
  108.     unsigned long                     groupCount;
  109.                                                                 /*     unsigned long        group1SrcCount;*/
  110.                                                                 /*     unsigned long        group1SrcEntrySize = sizeof(ScrapTypeSpec);*/
  111.                                                                 /*  ScrapTypeSpec        group1SrcTypes[group1SrcCount]*/
  112.                                                                 /*  unsigned long        group1DstCount;*/
  113.                                                                 /*     unsigned long        group1DstEntrySize = sizeof(ScrapTypeSpec);*/
  114.                                                                 /*  ScrapTypeSpec        group1DstTypes[group1DstCount]*/
  115. };
  116. typedef struct ScrapTranslationList        ScrapTranslationList;
  117. typedef ScrapTranslationList *            ScrapTranslationListPtr;
  118. typedef ScrapTranslationListPtr *        ScrapTranslationListHandle;
  119. /* definition of callbacks to update progress dialog*/
  120.  
  121. typedef long                             TranslationRefNum;
  122. /*****************************************************************************************
  123. *
  124. * This routine sets the advertisement in the top half of the progress dialog.
  125. * It is called once at the beginning of your DoTranslateFile routine.
  126. *
  127. * Enter:    refNum            Translation reference supplied to DoTranslateFile.
  128. *            advertisement    A handle to the picture to display.  This must be non-purgable.
  129. *                            Before returning from DoTranslateFile, you should dispose
  130. *                            of the memory.  (Normally, it is in the temp translation heap
  131. *                            so it is cleaned up for you.)
  132. *
  133. * Exit:    returns            noErr, paramErr, or memFullErr
  134. */
  135. EXTERN_API( OSErr )
  136. SetTranslationAdvertisement        (TranslationRefNum         refNum,
  137.                                  PicHandle                 advertisement)                        TWOWORDINLINE(0x7002, 0xABFC);
  138.  
  139.  
  140. /*****************************************************************************************
  141. *
  142. * This routine updates the progress bar in the progress dialog.
  143. * It is called repeatedly from within your DoTranslateFile routine.
  144. * It should be called often, so that the user will get feedback if he tries to cancel.
  145. *
  146. * Enter:    refNum        translation reference supplied to DoTranslateFile.
  147. *            progress    percent complete (0-100)
  148. *
  149. * Exit:        canceled    TRUE if the user clicked the Cancel button, FALSE otherwise
  150. *            returns        noErr, paramErr, or memFullErr
  151. */
  152. EXTERN_API( OSErr )
  153. UpdateTranslationProgress        (TranslationRefNum         refNum,
  154.                                  short                     percentDone,
  155.                                  Boolean *                canceled)                            TWOWORDINLINE(0x7001, 0xABFC);
  156.  
  157.  
  158.  
  159. /* ComponentMgr selectors for routines*/
  160.  
  161. enum {
  162.     kTranslateGetFileTranslationList = 0,                        /* component selectors*/
  163.     kTranslateIdentifyFile        = 1,
  164.     kTranslateTranslateFile        = 2,
  165.     kTranslateGetTranslatedFilename = 3,
  166.     kTranslateGetScrapTranslationList = 10,                        /* skip to scrap routines*/
  167.     kTranslateIdentifyScrap        = 11,
  168.     kTranslateTranslateScrap    = 12
  169. };
  170.  
  171.  
  172. /* Routines to implment in a file translation extension*/
  173.  
  174.  
  175. typedef CALLBACK_API( ComponentResult , DoGetFileTranslationListProcPtr )(ComponentInstance self, FileTranslationListHandle translationList);
  176. typedef CALLBACK_API( ComponentResult , DoIdentifyFileProcPtr )(ComponentInstance self, const FSSpec *theDocument, FileType *docType);
  177. typedef CALLBACK_API( ComponentResult , DoTranslateFileProcPtr )(ComponentInstance self, TranslationRefNum refNum, const FSSpec *sourceDocument, FileType srcType, long srcTypeHint, const FSSpec *dstDoc, FileType dstType, long dstTypeHint);
  178. typedef CALLBACK_API( ComponentResult , DoGetTranslatedFilenameProcPtr )(ComponentInstance self, FileType dstType, long dstTypeHint, FSSpec *theDocument);
  179.  
  180. /* Routine to implement in a scrap translation extension*/
  181.  
  182. typedef CALLBACK_API( ComponentResult , DoGetScrapTranslationListProcPtr )(ComponentInstance self, ScrapTranslationListHandle list);
  183. typedef CALLBACK_API( ComponentResult , DoIdentifyScrapProcPtr )(ComponentInstance self, const void *dataPtr, Size dataLength, ScrapType *dataFormat);
  184. typedef CALLBACK_API( ComponentResult , DoTranslateScrapProcPtr )(ComponentInstance self, TranslationRefNum refNum, const void *srcDataPtr, Size srcDataLength, ScrapType srcType, long srcTypeHint, Handle dstData, ScrapType dstType, long dstTypeHint);
  185.  
  186.  
  187.  
  188.  
  189. #if PRAGMA_STRUCT_ALIGN
  190.     #pragma options align=reset
  191. #elif PRAGMA_STRUCT_PACKPUSH
  192.     #pragma pack(pop)
  193. #elif PRAGMA_STRUCT_PACK
  194.     #pragma pack()
  195. #endif
  196.  
  197. #ifdef PRAGMA_IMPORT_OFF
  198. #pragma import off
  199. #elif PRAGMA_IMPORT
  200. #pragma import reset
  201. #endif
  202.  
  203. #ifdef __cplusplus
  204. }
  205. #endif
  206.  
  207. #endif /* __TRANSLATIONEXTENSIONS__ */
  208.  
  209.